package com.google.shop.product.wxlogin;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;

/* loaded from: app.jar:BOOT-INF/classes/com/google/shop/product/wxlogin/WxUtil.class */
public class WxUtil {
    public static String sendPost(String param, String url) throws IOException {
        BufferedReader in = null;
        PrintWriter out = null;
        try {
            out = null;
            in = null;
            String result = "";
            try {
                URLConnection conn = new URL(url).openConnection();
                conn.setRequestProperty("accept", "*/*");
                conn.setRequestProperty("connection", "Keep-Alive");
                conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
                conn.setDoOutput(true);
                conn.setDoInput(true);
                out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), "utf-8"));
                out.print(param);
                out.flush();
                in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
                while (true) {
                    String line = in.readLine();
                    if (line == null) {
                        break;
                    }
                    result = result + line;
                }
                if (out != null) {
                    try {
                        out.close();
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
                if (in != null) {
                    in.close();
                }
            } catch (Exception e) {
                System.out.println("发送 POST 请求出现异常！" + e);
                e.printStackTrace();
                if (out != null) {
                    try {
                        out.close();
                    } catch (Exception ex2) {
                        ex2.printStackTrace();
                    }
                }
                if (in != null) {
                    in.close();
                }
            }
            return result;
        } catch (Throwable th) {
            if (out != null) {
                out.close();
            }
            if (in != null) {
                in.close();
            }
            throw th;
        }
    }
}
